package com.nutquest.common.dataobjects;

import java.io.*;
import java.util.ArrayList;

/**
 * This class exists as the ground in the nut quest game.
 */
public class Player implements ICoordinate, ICarry, Serializable {
	private static final long serialVersionUID = 713311659347425252L;
	private String name = "";
	private int x = -1;
	private int y = -1;
	private ArrayList<Object> objects;
	private PlayerState state;
	private String sentMsg = null;

	/**
	 * Constructor, defaults to PlayerState.LOBBY
	 * 
	 * @param type The type of Terrain that this object is. Tree Player is
	 *       impasseble, and Grass isn't.
	 */
	public Player(String name, int x, int y) {
		this.x = x;
		this.y = y;
		this.name = name;
		this.state = PlayerState.LOBBY;
	}

	/**
	 * Constructor
	 * 
	 * @param type The type of Player that this object is. Tree Player is
	 *       impasseble, and Grass isn't.
	 * @param state The PlayerState that this player is currently on.
	 */
	public Player(String name, PlayerState state, int x, int y) {
		this.x = x;
		this.y = y;
		this.name = name;
		this.state = state;
		this.objects = new ArrayList<Object>();
	}

	/**
	 * Constructor
	 * 
	 * @param type The type of Player that this object is. Tree Player is
	 *       impasseble, and Grass isn't.
	 * @param state The PlayerState that this player is currently on.
	 * @param objects The collection of objects that this Player object contains,
	 *       usually nuts.
	 */
	public Player(String name, PlayerState state, ArrayList<Object> objects,
			int x, int y) {
		this.x = x;
		this.y = y;
		this.name = name;
		this.objects = objects;
		this.state = state;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return this.name;

	}

	/**
	 * Set X.
	 */
	public void setX(int x) {
		this.x = x;
	}

	/**
	 * Set Y.
	 */
	public void setY(int y) {
		this.y = y;
	}

	/**
	 * Get X.
	 */
	public int getX() {
		return this.x;
	}

	/**
	 * Get Y.
	 */
	public int getY() {
		return this.y;
	}

   public PlayerState getState() {
      return this.state;
   }

   public void setState(PlayerState state) {
      this.state = state;
   }

	/**
	 * Get the contents of this Player object.
	 */
	public ArrayList<Object> getObjects() {
		return objects;
	}

	/**
	 * Set the contents of this Player object.
	 */
	public void setObjects(ArrayList<Object> objects) {
		this.objects = objects;
	}

	public String getSentMsg() {
		return sentMsg;
	}

	public void setSentMsg(String sentMsg) {
		this.sentMsg = sentMsg;
	}
	
	@Override
	public boolean hasObjects() {
		// TODO Auto-generated method stub
		if(this.objects != null)
		{
			if(this.objects.size() > 0)
				return true;
		}
		return false;
	}

	/**
	 * This is the list of states that a Player object can be in.
	 */
	public enum PlayerState {
		LOBBY, FORAGING, ROCK_PAPER_SCISSORS
	}

}